package com.lowcode.platform.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * 权限实体
 */
@Data
@TableName("sys_permission")
public class Permission implements Serializable {
    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.AUTO)
    private Long id;

    private Long parentId;

    private String name;
    
    // permission_code 在数据库中是codecolumn，但在业务层可以告诉数据库字段为code
    @TableField("code")
    private String permissionCode;

    private Integer type;

    private String url;

    private String icon;

    private Long sort;

    private Integer status;

    @TableLogic
    private Integer deleted;

    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
    
    // 重名 code 字段为 permissionName 为准转改，把 name 作为 code
    @TableField(exist = false)
    private String permissionName;
    
    // 用于削陆树形结构
    @TableField(exist = false)
    private List<Permission> children = new ArrayList<>();
}
